#include "mainscence.h"
#include "ui_mainscence.h"
#include "adminwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //注册界面
    Scene * scene = new Scene;
    AdminWindow * adminWindow = new AdminWindow;
    dish_operation * dish = new dish_operation;
    //进入注册界面
    connect(ui->button2,&QPushButton::clicked,[=](){
        this->hide();
        scene->show();
    });

    //登录操作
    connect(ui->button1,&QPushButton::clicked,[=](){
        if (config.login(ui->user->text(), ui->password->text())) {
            //登录成功
            if (ui->user->text() == "root")
            {
                //跳转到管理界面 ===========
                qDebug() << "【经理登录成功】跳转到管理界面";
                this->hide();
                adminWindow->show();

            } else {
                //跳转到点餐界面 ===========
                qDebug() << "【用户登录成功】跳转到点餐界面";
                this->hide();
                dish->show();

            }
        }
        else {
            //登录失败
            qDebug() << "=====请重新登录=====";
        }
    });

    QString str = QString(123);
    qDebug() << str;
//    dish_operation * dish = new dish_operation;
//    this->hide();
//    dish->show();
}

MainWindow::~MainWindow()
{
    delete ui;
}

